<?php

namespace App\Repositories;

use App\Exceptions\BasicException;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Redis;
use function Matrix\add;    //引入hash

class AreaRepository {

    /**
     * 获取所有省份列表
     */
    public function getAllProvinceList() {
        $result = app('model_district')->where(["level" => 1])->get();

        return $result;
    }

    /**
     * 获取所有市列表
     */
    public function getAllCityList($where = []) {
        $result = app('model_district')->where($where)->get();

        return $result;
    }

    /**
     * 获取单个
     */
    public function getDistrict($id) {
        $result = app('model_district')->where(["district_id" => $id])->first();

        return $result;
    }

    /**
     * 新增
     * @param $param
     * @return bool
     * @throws BasicException
     */
    public function add($param) {
        $addConfig = app('model_district')->create($param);

        if ($addConfig) return $addConfig;
        throw new BasicException(93045);
    }

}